import WinterUtil from '@/utils/WinterUtil'

/**
 * 获取antd分页对象的页号
 * @param antdPagination
 */
export function getAntdPaginationPageNO (antdPagination) {
  return antdPagination.current
}

/**
 * 获取antd分页对象的分页大小(每页显示记录数)
 * @param antdPagination
 */
export function getAntdPaginationSize (antdPagination) {
  return antdPagination.pageSize
}

/**
 * 提取查询关键词. 如果otherCdt为字符串类型,则这个就是查询关键词, 如果otherCdt是对象,则使用他的kw属性作为查询关键词, 否则返回空字符串
 * @param otherCdt
 * @return {string}
 */
export function getKw (otherCdt) {
  let kw = ''
  if (otherCdt) {
    if (typeof otherCdt === 'string' && !WinterUtil.strIsBlank(otherCdt)) {
      kw = WinterUtil.strTrim(otherCdt)
    } else if (typeof otherCdt === 'object' && !WinterUtil.strIsBlank(otherCdt.kw)) {
      kw = WinterUtil.strTrim(otherCdt.kw)
    }
  }
  return kw
}

export default {
  getAntdPaginationPageNO, getAntdPaginationSize, getKw
}
